import store  from "@/store/index.js";
//  获取字典方法 使用示例 getDict('sex').then(res)  或者 async函数下 const res = await getDict('sex')
export const getDict = async (type, isThrottle = true) => {  //type-  字典 type， isThrottle： 节流
  await store.dispatch("dictionary/getDictionary", { types: type, isThrottle });
  const dict = {};
  if (typeof type === "string") {
    dict[type] = store.getters["dictionary/getDictionary"][type];
  } else if (typeof type === "object" && type.constructor === Array) {
    type.forEach((i) => {
      dict[i] = store.getters["dictionary/getDictionary"][i];
    });
  }
  return dict;
};
